package com.ruiboyun.liveapp.presenter.impl;

import com.ruiboyun.liveapp.base.Url;
import com.ruiboyun.liveapp.bean.LaunchBean;
import com.ruiboyun.liveapp.http.OkHttpManager;
import com.ruiboyun.liveapp.http.OnResponseListener;
import com.ruiboyun.liveapp.presenter.ConnectPresenter;
import com.ruiboyun.liveapp.util.tool.Loger;
import com.ruiboyun.liveapp.view.BaseView;
import com.ruiboyun.liveapp.view.ConnectView;

/**
 * Created by wushiqian on 2017/9/16.
 */

public class ConnectPresenterImpl extends BasePresenterImpl implements ConnectPresenter {
    public ConnectPresenterImpl(BaseView baseView) {
        super(baseView);
    }

    @Override
    public void connect() {
        OkHttpManager.getInstance().get(Url.LAUNCH,LaunchBean.class, new OnResponseListener<LaunchBean>() {
            @Override
            public void Success(LaunchBean o) {
                Loger.e("成功");
              getView().connectSuccess(o);

            }

            @Override
            public void onFailed(int errorCode) {
                Loger.e("失败"+errorCode);
                getView().connectError(errorCode);
            }

            @Override
            public void onException(String msg) {
                Loger.e("失败"+msg);
               getView().showTips(msg);
            }
        });
    }

    @Override
    public ConnectView getView() {
        return (ConnectView) baseView;
    }
}
